// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/*!
 * @file inner_const_and_typedefTypeObjectSupport.cxx
 * Source file containing the implementation to register the TypeObject representation of the described types in the IDL file
 *
 * This file was generated by the tool fastddsgen (version: 4.2.0).
 */

#include "inner_const_and_typedefTypeObjectSupport.hpp"

#include <mutex>
#include <string>

#include <fastcdr/xcdr/external.hpp>
#include <fastcdr/xcdr/optional.hpp>
#include <fastdds/dds/domain/DomainParticipantFactory.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastdds/dds/xtypes/common.hpp>
#include <fastdds/dds/xtypes/type_representation/ITypeObjectRegistry.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObject.hpp>
#include <fastdds/dds/xtypes/type_representation/TypeObjectUtils.hpp>
#include "inner_const_and_typedef.hpp"

#include "helpers/basic_inner_types.hpp"

using namespace eprosima::fastdds::dds::xtypes;


namespace AnnotationTest {

    void register_Inner_alias_bounded_string_helper_type_identifier(
            TypeIdentifierPair& type_ids_Inner_alias_bounded_string_helper)
    {
        ReturnCode_t return_code_Inner_alias_bounded_string_helper {eprosima::fastdds::dds::RETCODE_OK};
        return_code_Inner_alias_bounded_string_helper =
            eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
            "AnnotationTest::Inner_alias_bounded_string_helper", type_ids_Inner_alias_bounded_string_helper);
        if (eprosima::fastdds::dds::RETCODE_OK != return_code_Inner_alias_bounded_string_helper)
        {
            AliasTypeFlag alias_flags_Inner_alias_bounded_string_helper = 0;
            QualifiedTypeName type_name_Inner_alias_bounded_string_helper = "AnnotationTest::Inner_alias_bounded_string_helper";
            eprosima::fastcdr::optional<AppliedBuiltinTypeAnnotations> type_ann_builtin_Inner_alias_bounded_string_helper;
            eprosima::fastcdr::optional<AppliedAnnotationSeq> ann_custom_Inner_alias_bounded_string_helper;
            CompleteTypeDetail detail_Inner_alias_bounded_string_helper = TypeObjectUtils::build_complete_type_detail(type_ann_builtin_Inner_alias_bounded_string_helper, ann_custom_Inner_alias_bounded_string_helper, type_name_Inner_alias_bounded_string_helper.to_string());
            CompleteAliasHeader header_Inner_alias_bounded_string_helper = TypeObjectUtils::build_complete_alias_header(detail_Inner_alias_bounded_string_helper);
            AliasMemberFlag related_flags_Inner_alias_bounded_string_helper = 0;
            return_code_Inner_alias_bounded_string_helper =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "anonymous_string_1", type_ids_Inner_alias_bounded_string_helper);

            if (eprosima::fastdds::dds::RETCODE_OK != return_code_Inner_alias_bounded_string_helper)
            {
                {
                    SBound bound = static_cast<SBound>(1);
                    StringSTypeDefn string_sdefn = TypeObjectUtils::build_string_s_type_defn(bound);
                    if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                            TypeObjectUtils::build_and_register_s_string_type_identifier(string_sdefn,
                            "anonymous_string_1", type_ids_Inner_alias_bounded_string_helper))
                    {
                        EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                            "anonymous_string_1 already registered in TypeObjectRegistry for a different type.");
                    }
                }
            }
            bool common_Inner_alias_bounded_string_helper_ec {false};
            CommonAliasBody common_Inner_alias_bounded_string_helper {TypeObjectUtils::build_common_alias_body(related_flags_Inner_alias_bounded_string_helper,
                    TypeObjectUtils::retrieve_complete_type_identifier(type_ids_Inner_alias_bounded_string_helper, common_Inner_alias_bounded_string_helper_ec))};
            if (!common_Inner_alias_bounded_string_helper_ec)
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION, "AnnotationTest::Inner_alias_bounded_string_helper related TypeIdentifier inconsistent.");
                return;
            }
            eprosima::fastcdr::optional<AppliedBuiltinMemberAnnotations> member_ann_builtin_Inner_alias_bounded_string_helper;
            ann_custom_Inner_alias_bounded_string_helper.reset();
            CompleteAliasBody body_Inner_alias_bounded_string_helper = TypeObjectUtils::build_complete_alias_body(common_Inner_alias_bounded_string_helper,
                    member_ann_builtin_Inner_alias_bounded_string_helper, ann_custom_Inner_alias_bounded_string_helper);
            CompleteAliasType alias_type_Inner_alias_bounded_string_helper = TypeObjectUtils::build_complete_alias_type(alias_flags_Inner_alias_bounded_string_helper,
                    header_Inner_alias_bounded_string_helper, body_Inner_alias_bounded_string_helper);
            if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                    TypeObjectUtils::build_and_register_alias_type_object(alias_type_Inner_alias_bounded_string_helper,
                        type_name_Inner_alias_bounded_string_helper.to_string(), type_ids_Inner_alias_bounded_string_helper))
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                    "AnnotationTest::Inner_alias_bounded_string_helper already registered in TypeObjectRegistry for a different type.");
            }
        }
    }




} // namespace AnnotationTest

void register_AnnotationTest_type_identifier(
        TypeIdentifierPair& type_ids_AnnotationTest)
{
    ReturnCode_t return_code_AnnotationTest {eprosima::fastdds::dds::RETCODE_OK};
    return_code_AnnotationTest =
        eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
        "AnnotationTest", type_ids_AnnotationTest);
    if (eprosima::fastdds::dds::RETCODE_OK != return_code_AnnotationTest)
    {
        AnnotationTypeFlag annotation_flag_AnnotationTest = 0;
        QualifiedTypeName annotation_name_AnnotationTest = "AnnotationTest";
        CompleteAnnotationHeader header_AnnotationTest = TypeObjectUtils::build_complete_annotation_header(annotation_name_AnnotationTest);
        CompleteAnnotationParameterSeq member_seq_AnnotationTest;
        {
            ReturnCode_t return_code_var_string_10;
            TypeIdentifierPair type_ids_var_string_10;
            AnnotationParameterFlag member_flags_var_string_10 = 0;
            return_code_var_string_10 =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "AnnotationTest::Inner_alias_bounded_string_helper", type_ids_var_string_10);

            if (return_code_var_string_10 != eprosima::fastdds::dds::RETCODE_OK)
            {
                ::AnnotationTest::register_Inner_alias_bounded_string_helper_type_identifier(type_ids_var_string_10);
            }
            CommonAnnotationParameter common_var_string_10;
            if (EK_COMPLETE == type_ids_var_string_10.type_identifier1()._d() || TK_NONE == type_ids_var_string_10.type_identifier2()._d())
            {
                common_var_string_10 = TypeObjectUtils::build_common_annotation_parameter(member_flags_var_string_10, type_ids_var_string_10.type_identifier1());
            }
            else if (EK_COMPLETE == type_ids_var_string_10.type_identifier2()._d())
            {
                common_var_string_10 = TypeObjectUtils::build_common_annotation_parameter(member_flags_var_string_10, type_ids_var_string_10.type_identifier2());
            }
            else
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                        "var_string_10 annotation parameter TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_var_string_10 = "var_string_10";
            AnnotationParameterValue param_value_var_string_10 = TypeObjectUtils::build_annotation_parameter_value(eprosima::fastcdr::fixed_string<128>(""));


            CompleteAnnotationParameter param_var_string_10 = TypeObjectUtils::build_complete_annotation_parameter(common_var_string_10, name_var_string_10, param_value_var_string_10);
            TypeObjectUtils::add_complete_annotation_parameter(member_seq_AnnotationTest, param_var_string_10);
        }
        {
            ReturnCode_t return_code_var_default_string_10;
            TypeIdentifierPair type_ids_var_default_string_10;
            AnnotationParameterFlag member_flags_var_default_string_10 = 0;
            return_code_var_default_string_10 =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "AnnotationTest::Inner_alias_bounded_string_helper", type_ids_var_default_string_10);

            if (return_code_var_default_string_10 != eprosima::fastdds::dds::RETCODE_OK)
            {
                ::AnnotationTest::register_Inner_alias_bounded_string_helper_type_identifier(type_ids_var_default_string_10);
            }
            CommonAnnotationParameter common_var_default_string_10;
            if (EK_COMPLETE == type_ids_var_default_string_10.type_identifier1()._d() || TK_NONE == type_ids_var_default_string_10.type_identifier2()._d())
            {
                common_var_default_string_10 = TypeObjectUtils::build_common_annotation_parameter(member_flags_var_default_string_10, type_ids_var_default_string_10.type_identifier1());
            }
            else if (EK_COMPLETE == type_ids_var_default_string_10.type_identifier2()._d())
            {
                common_var_default_string_10 = TypeObjectUtils::build_common_annotation_parameter(member_flags_var_default_string_10, type_ids_var_default_string_10.type_identifier2());
            }
            else
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                        "var_default_string_10 annotation parameter TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_var_default_string_10 = "var_default_string_10";
            AnnotationParameterValue param_value_var_default_string_10 = TypeObjectUtils::build_annotation_parameter_value(eprosima::fastcdr::fixed_string<128>("Hello"));


            CompleteAnnotationParameter param_var_default_string_10 = TypeObjectUtils::build_complete_annotation_parameter(common_var_default_string_10, name_var_default_string_10, param_value_var_default_string_10);
            TypeObjectUtils::add_complete_annotation_parameter(member_seq_AnnotationTest, param_var_default_string_10);
        }
        {
            ReturnCode_t return_code_var_wstring_alias;
            TypeIdentifierPair type_ids_var_wstring_alias;
            AnnotationParameterFlag member_flags_var_wstring_alias = 0;
            return_code_var_wstring_alias =
                eprosima::fastdds::dds::DomainParticipantFactory::get_instance()->type_object_registry().get_type_identifiers(
                "Inner_alias_bounded_wstring_helper", type_ids_var_wstring_alias);

            if (return_code_var_wstring_alias != eprosima::fastdds::dds::RETCODE_OK)
            {
        ::register_Inner_alias_bounded_wstring_helper_type_identifier(type_ids_var_wstring_alias);
            }
            CommonAnnotationParameter common_var_wstring_alias;
            if (EK_COMPLETE == type_ids_var_wstring_alias.type_identifier1()._d() || TK_NONE == type_ids_var_wstring_alias.type_identifier2()._d())
            {
                common_var_wstring_alias = TypeObjectUtils::build_common_annotation_parameter(member_flags_var_wstring_alias, type_ids_var_wstring_alias.type_identifier1());
            }
            else if (EK_COMPLETE == type_ids_var_wstring_alias.type_identifier2()._d())
            {
                common_var_wstring_alias = TypeObjectUtils::build_common_annotation_parameter(member_flags_var_wstring_alias, type_ids_var_wstring_alias.type_identifier2());
            }
            else
            {
                EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                        "var_wstring_alias annotation parameter TypeIdentifier inconsistent.");
                return;
            }
            MemberName name_var_wstring_alias = "var_wstring_alias";
            AnnotationParameterValue param_value_var_wstring_alias = TypeObjectUtils::build_annotation_parameter_value(static_cast<std::wstring>(L""));


            CompleteAnnotationParameter param_var_wstring_alias = TypeObjectUtils::build_complete_annotation_parameter(common_var_wstring_alias, name_var_wstring_alias, param_value_var_wstring_alias);
            TypeObjectUtils::add_complete_annotation_parameter(member_seq_AnnotationTest, param_var_wstring_alias);
        }
        CompleteAnnotationType annotation_type_AnnotationTest = TypeObjectUtils::build_complete_annotation_type(annotation_flag_AnnotationTest, header_AnnotationTest,
                member_seq_AnnotationTest);
        if (eprosima::fastdds::dds::RETCODE_BAD_PARAMETER ==
                TypeObjectUtils::build_and_register_annotation_type_object(annotation_type_AnnotationTest,
                    annotation_name_AnnotationTest.to_string(), type_ids_AnnotationTest))
        {
            EPROSIMA_LOG_ERROR(XTYPES_TYPE_REPRESENTATION,
                "AnnotationTest already registered in TypeObjectRegistry for a different type.");
        }
    }
}

